package dfs;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 给定一个整型数组, 你的任务是找到所有该数组的递增子序列，递增子序列的长度至少是 2 。
 * 输入：[4, 6, 7, 7]
 * 输出：[[4, 6], [4, 7], [4, 6, 7], [4, 6, 7, 7], [6, 7], [6, 7, 7], [7,7], [4,7,7]]
 * @author le
 */
public class IncreaseSubSequence
{
    private static List<List<Integer>> res = new ArrayList<>();

    public static void main(String[] args)
    {
        int[] nums = {4, 6, 7, 7};
        ArrayList<Integer> arr = new ArrayList<>();
        backtrack(0,arr, nums);
        for (List<Integer> tmp : res){
            System.out.println(tmp.toString());
        }

    }

    public List<List<Integer>> findSubsequences(int[] nums) {
        return null;
    }

    private static void backtrack(int level, List<Integer> tmp, int[] nums){
        if (level == nums.length){
            res.add(tmp);
        }else{

            for (int i = level;i < nums.length; i++){
                tmp.add(nums[level]);
                backtrack(level+1, tmp, nums);
                tmp.remove(level);
            }
        }
    }
}
